package com.eastfair.projectcore.api;

import com.alibaba.fastjson.JSONObject;
import com.eastfair.core.base.R;
import com.eastfair.model.DataIsolationVo;
import com.eastfair.model.TenantRuleVO;
import com.eastfair.projectcore.dto.DataIsolationDTO;
import com.eastfair.projectcore.dto.InterfaceInfoDTO;
import com.eastfair.projectcore.dto.MenuDTO;
import com.eastfair.projectcore.dto.TenantRuleDTO;
import com.eastfair.projectcore.entity.Area;
import com.eastfair.projectcore.entity.InterfaceInfo;
import com.eastfair.projectcore.entity.ProjectDb;
import com.eastfair.projectcore.entity.WorkerNode;
import com.eastfair.projectcore.hystrix.ProjectCoreApiFallback;
import com.eastfair.projectcore.vo.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * feign接口
 *
 * @Author ligang
 * @Date 2020/3/16 16:41
 */
@FeignClient(value = "project-core", fallback = ProjectCoreApiFallback.class)
public interface ProjectCoreServiceFeign {

    /**
     * 查询项目接口
     *
     * @return
     */
    @GetMapping("/projectDb/getById")
    R<ProjectDb> getProjectById(@RequestParam(value = "projectId") Long projectId);



    /**
     * 查询项目接口
     *
     * @return
     */
    @PostMapping("/dataIsolation/queryList")
    R<List<DataIsolationVo>> queryDataIsolaction(@RequestBody DataIsolationDTO dataIsolationDTO);

    /**
     * 字典查询
     *
     * @return
     */
    @PostMapping("/dict/findByNames")
    Map<Serializable, Object> findByNames(@RequestBody Set<Serializable> types);


    /**
     * 通过子菜单查询菜单信息和全部子信息
     *
     * @return
     */
    @PostMapping("/menu/findAllByChildId")
    R<List<MenuVO>> findAllByChildId(@RequestBody MenuDTO menuDTO);

    /**
     * 通过子菜单查询菜单信息和全部子信息（不含按钮）
     *
     * @return
     */
    @PostMapping("/menu/findAllByChildIdNoButton")
    R<List<MenuVO>> findAllByChildIdNoButton(@RequestBody MenuDTO menuDTO);

    /**
     * 查询菜单的权限标识
     *
     * @param menuDTO 菜单实体
     * @return 查询结果
     */
    @ApiOperation(value = "查询菜单的权限标识", notes = "查询菜单的权限标识")
    @PostMapping("/menu/findPermissionAllByChildId")
    R<List<String>> findPermissionAllByChildId(@RequestBody MenuDTO menuDTO);




    /**
     * 查询菜单的权限标识
     *
     * @param menuDTO 菜单实体
     * @return 查询结果
     */
    @ApiOperation(value = "查询菜单的权限标识", notes = "查询菜单的权限标识")
    @PostMapping("/menu/findInterfaceAllByChildId")
    R<List<String>> findInterfaceAllByChildId(@RequestBody MenuDTO menuDTO);



    /**
     * 推荐橱窗
     *
     * @return
     */
    @GetMapping("/hotImage/recommendHotImage")
    R recommendHotImage(@RequestParam(value = "id") Long id, @RequestParam(value = "isRecommend") Boolean isRecommend);


    /**
     * 置顶橱窗
     *
     * @return
     */
    @GetMapping("/hotImage/top")
    R top(@RequestParam(value = "id") Long id);

    /**
     * 通过id获取地区
     *
     * @param id 地区id
     * @return 地区实体
     */
    @ApiOperation(value = "通过id获取地区", notes = "通过id获取地区")
    @GetMapping("/area/find/{id}")
    R<Area> getAreaById(@PathVariable("id") Integer id);

    /**
     * 查询某地区电话区号
     *
     * @param id 地区id
     * @return 地区区号
     */
    @ApiOperation(value = "查询某地区电话区号", notes = "查询某地区电话区号")
    @GetMapping("/getPhoneCodeByAreaId/{id}")
    R<String> getPhoneCodeByAreaId(@PathVariable("id") Integer id);


    /**
     * 校对验证码
     *
     * @param verifyId
     * @param verifyValue
     * @return
     */
    @GetMapping("/kaptcha/imgvrify")
    R<Boolean> imgvrify(@RequestParam(value = "verifyId") String verifyId, @RequestParam(value = "verifyValue") String verifyValue);


    /**
     * 查询地区list
     *
     * @param area 区域级别
     * @return 地区列表
     */
    @ApiOperation(value = "查询地区list", notes = "查询地区list")
    @PostMapping("/area/queryListArea")
    R<List<AreaVO>> queryListArea(@RequestBody Area area);


    /**
     * 创建worknode
     *
     * @return
     */
    @ApiOperation(value = "创建worknode", notes = "创建worknode")
    @PostMapping("/workerNode/createWorkNode")
    Long createWorkNode();


    /**
     * 查询全部菜单信息
     *
     * @return 查询结果
     */
    @ApiOperation(value = "查询全部菜单信息", notes = "查询全部菜单信息")
    @GetMapping("/menu/queryAllMenuId")
    R<List<Long>> queryAllMenuId();


    /**
     * 查询最子集菜单信息
     *
     * @return 查询结果
     */
    @ApiOperation(value = "查询最子集菜单信息(前端要)", notes = "查询最子集菜单信息")
    @PostMapping("/menu/queryBestChildMenuId")
    R<List<Long>> queryBestChildMenuId(@RequestBody List<Long> menuIds);

    /**
     * 查询全量数据
     */
    @ApiOperation(value = "查询全量数据", notes = "查询全量数据")
    @GetMapping("/tenantRule/queryTenantTable")
    R<List<TenantRuleVO>> queryTenantTable();


    /**
     * 执行添加接口参数
     *
     * @param interfaceInfos 系统标识
     */
    @ApiOperation(value = "执行添加接口参数", notes = "执行添加接口参数")
    @PostMapping("/interfaceInfo/executeAllUrl")
    R executeAllUrl(@RequestBody List<JSONObject> interfaceInfos);


    /**
     * 查询系统
     */
    @ApiOperation(value = "查询系统", notes = "查询系统")
    @PostMapping("/interfaceInfo/querySystem")
    R<List<InterfaceInfo>> querySystem(@RequestBody InterfaceInfoDTO interfaceInfoDTO) ;

    /**
     * 创建百度worknode
     * @return
     */
    @ApiOperation(value = "创建百度worknode", notes = "创建百度worknode")
    @PostMapping("/workerNode/createBaiduWorkNode")
    R<WorkerNode> createBaiduWorkNode(@RequestBody WorkerNode workerNodeEntity);

}
